package fpzhan.plane.program.manager;

import fpzhan.plane.program.proxy.CodeBlockProxy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ProxyManager {

    private Map<String, CodeBlockProxy> proxys = new HashMap<>();

    private List<String> useProxy = new ArrayList<>() ;

    public  void register(CodeBlockProxy proxy){
        proxys.put(proxy.getName(),proxy);
    }

    public  void useKey(String... proxyNames){
        useProxy = Arrays.asList(proxyNames);
    }

    public  List<CodeBlockProxy> getProxys(){
        return proxys.entrySet().stream().filter(entry-> useProxy.contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
    }
}
